package _99练习;

import java.util.jar.Attributes.Name;

//扑克牌类
public class Poker implements Comparable<Poker>{

	// 用字符串串表示
	
//	// 花色
//	String type;
//	// 数字
//	String num;
//	
//	@Override
//	public String toString() {
//		return type + num;
//	}
	
	// 数字表示
//	int type; // 1 2 3 4 黑桃  红桃 草花 方片
//	int num;// 1~13  A~K
//	
//	@Override
//	public String toString() {
//		
//		String[] types = {"黑桃","红桃","草花","方片"};
//		String[] nums = {"A","1","2","3","4","5","6","7","8","9","10","J","Q","K"};
//		
//		return types[type-1] + nums[num-1];
//	}
//	
	
	
	int cardId;// 1~54
	// 1~13 黑桃		
	// 2~26 红桃
	// 27~39 草花
	// 40~52 方片
	// 53~54 大鬼小鬼
	
	@Override
	public String toString() {
		
		if(cardId==53) return "大鬼";
		if(cardId==54) return "小鬼";
		
		int type = (cardId-1) / 13 + 1; //  算花色
		int num = (cardId-1) % 13 + 1;  //  算牌数
		String[] types = {"♠","♦","♣","♥"}; 
		
			// {"黑桃","红桃","草花","方片"};
	 	String[] nums = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
		
		return types[type-1] + nums[num-1];
	}
	
	
	static Poker getCard()
	{
		Poker p = new Poker();
		p.cardId = (int)(Math.random()*54)+1;
		return p;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + cardId;
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Poker other = (Poker) obj;
		if (cardId != other.cardId)
			return false;
		return true;
	}


	@Override
	public int compareTo(Poker o) {
		// TODO Auto-generated method stub
		if(this.cardId<o.cardId)
			{
				return -1;
			}
			else if(this.cardId==o.cardId)
			{
				return 0;
			}
			else
			{
				return 1;
		    }
	}
	
	
	
	
}